﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class UserControls_Header:System.Web.UI.UserControl
{
	protected string ImageUrl;
	protected string BackGroundImage;
	protected void Page_Load(object sender,EventArgs e)
	{
		BindCatalogData();
		if(Request.RawUrl.IndexOf("Portal") > -1)
		{
			ImageUrl = "../Images/top(2.0).swf";
			BackGroundImage = "../Images/index.jpg";
			return;
		}
		if(Request.RawUrl.IndexOf("Admin") > -1)
		{
			ImageUrl = "../Images/top(2.0).swf";
			BackGroundImage = "../Images/index.jpg";
			return;
		}
		else
		{
			ImageUrl = "Images/top(2.0).swf";
			BackGroundImage = "Images/index.jpg";
		}		
	}

	/// <summary>
	/// 可以不直接访问数据库，即可以访问缓存的数据
	/// </summary>
	private void BindCatalogData()
	{
		ICatalog catalog = new Catalog();
		SqlDataReader dr = catalog.GetSubCatalog(1);

		CatalogList.DataSource = dr;
		CatalogList.DataBind();
		dr.Close();
	}

	protected string FormatCatalogUrl(int nUrlID,string url,
		int nCatalogID)
	{
		if(nUrlID == 0)
		{
			return Request.ApplicationPath + "/Portal/ViewCatalog.aspx?CatalogID=" + nCatalogID.ToString();
		}
		if(url.IndexOf("http://") > -1 || url.IndexOf("https://") > -1
			|| url.IndexOf("ftp://") > -1 || url.IndexOf("mailto:") > -1)
		{
			return url;
		}
		else
		{
			return (Request.ApplicationPath + "/" + url);
		}
	}

}
